package com.nbsaas.boot.project.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.common.data.entity.DataType;
import com.nbsaas.boot.jpa.data.entity.LongEntity;
import lombok.Data;
import org.hibernate.annotations.Comment;

import javax.persistence.*;


@org.hibernate.annotations.Table(appliesTo = "bs_business_model_item", comment = "业务模型字段")
@Data
@FormAnnotation(model = "业务模型字段")
@Entity
@Table(name = "bs_business_model_item")
public class BusinessModelField extends LongEntity {


    @Comment("项目ID")
    private Long projectId;


    @SearchItem(label = "业务模型", name = "businessModel",key = "businessModel.id",classType = Long.class,type = InputType.select)
    @FormField(title = "业务模型", grid = true, width = "200",type = InputType.select,option = "businessModel")
    @Comment("业务模型")
    @JoinColumn(name = "business_model_id")
    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private BusinessModel businessModel;

    @SearchItem(label = "字段名称", name = "name")
    @Comment("字段名称")
    @FormField(title = "字段名称",  grid = true, width = "200")
    @Column(length = 30)
    private String name;


    @SearchItem(label = "英文名称", name = "enName")
    @Comment("英文名称")
    @FormField(title = "英文名称",  grid = true, width = "200")
    @Column(length = 30)
    private String enName;

    @Comment("列表显示")
    @Dict(items = {
            @DictItem(value = 1, label = "显示"),
            @DictItem(value = 2, label = "不显示")
    })
    private Integer showType;



    @FormField(title = "数据类型", grid = true, width = "200",type = InputType.select,option = "dataType")
    @Comment("数据类型")
    @JoinColumn(name = "data_type_id")
    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private DataType dataType;

    @FormField(title = "字段描述",type = InputType.textarea)
    @Comment("字段描述")
    private String note;


}
